package study;
public class code03_jumpGame {
    public static int jump(int[] arr){
        if (arr == null || arr.length== 0) {
            return 0;
        }
        int jump = 0;
        int cur = 0;
        int next = 0;

        for (int i = 0; i < arr.length; i++) {
            if (cur < i) {
                jump++;
                cur = next;
                System.out.println(i);
            }
            next = Math.max(next, i+arr[i]);
        }
        return jump;
    }

    public static void main(String[] args) {
        int[] arr = {1,2,4,5,2,1,5,6,2,1,2,2,1,1,1};
        System.out.println(jump(arr));
    }
}
